<?php
/**
 * init plugin
 * @author Toan Nguyen
 */
elgg_register_action("skillmanagement/newskill", elgg_get_plugins_path() . "skillmanagement/actions/skillmanagement/addnewskill.php");
elgg_register_action("skillmanagement/usereditskill", elgg_get_plugins_path() . "skillmanagement/actions/skillmanagement/usereditskill.php");
elgg_register_event_handler('init', 'system', 'skil_init');

function skil_init(){

    elgg_register_page_handler('skill', 'skill_page_handler');
	elgg_extend_view('css/elements/forms', 'css/extenforms');
	elgg_extend_view('css/elgg', 'css/tooltip');	
	elgg_register_widget_type('skillmanagement', elgg_echo('skill:widget:title'), elgg_echo('skill:widget:description'));
    elgg_load_js('lightbox');
    elgg_load_css('lightbox');
};

function skill_page_handler($segments) {
	$base_path = elgg_get_plugins_path().'skillmanagement/pages/';
	switch($segments[0])
	{
		case 'newskill':
			include $base_path . 'skillmanagement/newskill.php';
			break;
		case 'forms':
			$form = $segments[1];
			if(!empty($form)){
				include $base_path . 'forms/'.$form.'.php';;
			}			
			break;
        default:
           break;		
	}
    return true;  
};
?>